#ifndef YINGCESERVICE_H
#define YINGCESERVICE_H
#include "libs/base/service/service.h"

namespace yc {
struct Attention;
struct LiveInfo;
struct Presenter;
struct RecordInfo;
class UserDetail;
}

class YingCeService : public yc::Service
{
    Q_OBJECT

public:
    explicit YingCeService(QObject* parent = nullptr);
    ~YingCeService();

    static YingCeService* instance() { return instance_; }
    void setAuthentication(const QString& access_token, const QString& refresh_token = QString());

    // Users
    int registerUser(const QString& name, const QString& password, const QString& auth_code,
                     const yc::ResponseHandler& handler);
    int loginByName(const QString& name, const QString& password, const QString& auth_code,
                    const QString& device, const yc::ResponseHandler& handler);
    int loginByToken(const QString& name, const QString& access_token,
                     const yc::ResponseHandler& handler);
    int refreshToken(const QString& refresh_token, const yc::ResponseHandler& handler);
    int logout(const yc::ResponseHandler& handler);
    int changeUser(const yc::UserDetail& detail, const yc::ResponseHandler& handler);
    int changeUserCover(const QString& cover, const yc::ResponseHandler& handler);
    int changeUserAvatar(const QString& avatar, const yc::ResponseHandler& handler);
    int changePassword(const QString& password, const QString& new_password,
                       const yc::ResponseHandler& handler);
    int deleteUser(int id, const yc::ResponseHandler& handler);

    // Platforms
    int getAllPlatforms(const yc::ResponseHandler& handler);
    int getLiveWebEntry(int platform, const yc::ResponseHandler& handler);

    // 主播(Presenter)
    int searchPresenters(int platform, const QString& keyword, int start_index,
                         const yc::ResponseHandler& handler);
    int getPresenters(const QList<int>& ids, const yc::ResponseHandler& handler);
    int getPresenter(int id, const yc::ResponseHandler& handler);
    int getPresenters(int platform, const QStringList& platform_ids,
                      const yc::ResponseHandler& handler);
    int addPresenter(const yc::Presenter& presenter, const yc::ResponseHandler& handler);
    int getPresenterStatus(int id, const yc::ResponseHandler& handler);
    int updatePresenterStatus(int id, int status, int active_live, int audience_count,
                              const yc::ResponseHandler& handler);

    // 主播列表(Attentions)
    int getAttentions(int page_num, const yc::ResponseHandler& handler);
    int addAttentions(const QList<yc::Attention>& attentions, const yc::ResponseHandler& handler);
    int changeAttentionAutoCheck(int id, bool auto_check, const yc::ResponseHandler& handler);
    int changeAttentionAutoRecord(int id, bool auto_check, const yc::ResponseHandler& handler);
    int changeAttentionCategory(int id, int category, const yc::ResponseHandler& handler);
    int deleteAttentions(const QList<int>& ids, const yc::ResponseHandler& handler);

    // 直播(Live)
    int getLive(int id, const yc::ResponseHandler& handler);
    int getLiveByPlatformId(const QString& platform_id, const yc::ResponseHandler& handler);
    int addLive(const yc::LiveInfo& live_info, const yc::ResponseHandler& handler);
    int getLiveStatus(int id, const yc::ResponseHandler& handler);
    int updateLiveStatus(int id, int status, int view_count, int like_count,
                         const yc::ResponseHandler& handler);

    // 录制(record)
    int getRecords(int presenter, int start_index, const yc::ResponseHandler& handler);
    int addRecord(const yc::RecordInfo& record, const yc::ResponseHandler& handler);
    int deleteRecords(const QList<int>& ids, const yc::ResponseHandler& handler);

private:
    static YingCeService* instance_;
};

#endif // YINGCESERVICE_H
